﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace NotMyBoom
{
    public class My2DSprite
    {
        private bool animated = true;

        public bool Animated
        {
            get { return animated; }
            set { animated = value; }
        }

        private Texture2D[] _Textures;

        public Texture2D[] Textures
        {
            get { return _Textures; }
            set { _Textures = value; }
        }
        private int _nTexture;

        public int nTexture
        {
            get { return _nTexture; }
            set { _nTexture = value; }
        }
        private int _curTexture;

        public int CurTexture
        {
            get { return _curTexture; }
            set { _curTexture = value; }
        }
        private Vector2 _Position;

        public Vector2 Position
        {
            get { return _Position; }
            set { _Position = value; }
        }

        public My2DSprite(Texture2D[] textures, int ntexture, Vector2 position)
        {
            _Textures = textures;
            _Position = position;
            _nTexture = ntexture;
        }

        private float _NormalDelay = 16.0f;

        public float NormalDelay
        {
            get { return _NormalDelay; }
            set { _NormalDelay = value; }
        }

        public void Update(GameTime gameTime)
        {
            if (animated)
            {
                int delta = (int)(gameTime.TotalGameTime.Milliseconds / _NormalDelay);
                _curTexture = delta % _nTexture;
            }
            else
                return;
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(_Textures[_curTexture], _Position, Color.White);
        }
    }
}
